/*
 * PathFinder.h
 *
 *  Created on: Mar 13, 2010
 *      Author: Vu Phuong Hoang
 */

#ifndef PATHFINDER_H_
#define PATHFINDER_H_

#include <list>
#include "Coordinate.h"
#include "TerrainMap.h"

template<class T>
class PathFinder {
protected:
	//map, starting point, finishing point, std::list stores path to go
	TerrainMap<T> kMap;
	Coordinate kStart, kFinish;
	std::list<Coordinate> akPath;

	//Some utility functions to determine position
	bool isInMap(Coordinate c);
	bool isStart(Coordinate c);
	bool isFinish(Coordinate c);
	bool isInPath(Coordinate c);
public:
	//Constructors
	PathFinder() :
		kMap( NULL ) {
	}
	PathFinder(TerrainMap<T> map) :
		kMap( map ) {
	}
	virtual ~PathFinder() {
	}

	//Setters
	void setMap(TerrainMap<T> map);

	//Getters
	std::list<Coordinate> getPath();
	TerrainMap<T> getMap();

	//Find path - main method
	/*virtual std::list<Coordinate> findPath(Coordinate from, Coordinate to) = 0;*/

	//Display path to console screen
	/*virtual void displayPath() = 0;
	 virtual void displayPathInMap() = 0;*/
};

template<class T>
bool PathFinder<T>::isInMap(Coordinate c) {
	return ((c.x >= 0) && (c.x < kMap.getRows()) && (c.y >= 0) && (c.y < kMap.getColumns()));
}

template<class T>
bool PathFinder<T>::isStart(Coordinate c) {
	return (c == kStart);
}

template<class T>
bool PathFinder<T>::isFinish(Coordinate c) {
	return (c == kFinish);
}

template<class T>
void PathFinder<T>::setMap(TerrainMap<T> map) {
	kMap = map;
}

template<class T>
std::list<Coordinate> PathFinder<T>::getPath() {
	return akPath;
}

template<class T>
TerrainMap<T> PathFinder<T>::getMap() {
	return kMap;
}

#endif /* PATHFINDER_H_ */
